import http from '@http'

// 按类型查询用户列表
export const createApplyGoOut = async data => {
  return await http({
    url: http.adornUrl(`/covid/outapplyrecord/save`),
    method: 'post',
    data
  })
}

export const fetchOldManArrangeList = async nurseId => {
  return await http({
    url: http.adornUrl(`/nursehome/user/get_old_man_arrange_list/${nurseId}`),
    method: 'get'
  })
}

// 创建申领记录
export const createSupplyRecord = async data => {
  return await http({
    url: http.adornUrl(`/covid/supplytakerecord/save`),
    method: 'post',
    data
  })
}

// 获取访客记录
export const getVisitorList = async params => {
  return await http({
    url: http.adornUrl(`/covid/visitor/list`),
    method: 'get',
    params: http.adornParams(params)
  })
}

// 获取物资记录
export const getSupplyList = async params => {
  return await http({
    url: http.adornUrl(`/covid/supplytakerecord/list`),
    method: 'get',
    params: http.adornParams(params)
  })
}

// 获取文章记录
export const getArticleList = async params => {
  return await http({
    url: http.adornUrl(`/covid/epidemicinformation/list`),
    method: 'get',
    params: http.adornParams(params)
  })
}

// 获取用户
export const getUserList = async params => {
  return await http({
    url: http.adornUrl(`/sys/user/list`),
    method: 'get',
    params: http.adornParams(params)
  })
}

// 获取文章具体
export const getArticleInfo = async id => {
  return await http({
    url: http.adornUrl(`/covid/epidemicinformation/info/${id}`),
    method: 'get'
  })
}

// 获取用户信息
export const getUserInfo = async id => {
  return await http({
    url: http.adornUrl(`/sys/user/info`),
    method: 'get'
  })
}


export const approve = async data =>{
  // eslint-disable-next-line no-return-await
  return await http({
    url: http.adornUrl(`/covid/outapplyrecord/approve?id=${data.id}&option=${data.option}`),
    method: 'post'
  })
}

// 创建用户
export function createUser (data) {
  return request({
    url: `${baseHead}/create_user`,
    method: 'post',
    data
  })
}

// 删除用户
export function deleteUser (userid) {
  const url = `${baseHead}/delete/${userid}`
  console.log(url)
  return request({
    url,
    method: 'delete'
  })
}

// 问卷设计者操作
export const designOpera = async data => {
  return await http({
    url: http.adornUrl(`/api/design`),
    method: 'post',
    data
  })
}

export function fetchArticle (id) {
  return request({
    url: '/vue-element-admin/article/detail',
    method: 'get',
    params: { id }
  })
}

export function fetchPv (pv) {
  return request({
    url: '/vue-element-admin/article/pv',
    method: 'get',
    params: { pv }
  })
}

export function createArticle (data) {
  return request({
    url: '/vue-element-admin/article/create',
    method: 'post',
    data
  })
}

export function updateArticle (data) {
  return request({
    url: '/vue-element-admin/article/update',
    method: 'post',
    data
  })
}
